package org.apache.xmlrpc.demo;

import java.sql.*;

//import java.io.*;


public class MysqlConnect {

	public static String connect(String id, String pass) {
		System.out.println("MySQL Connect Example.");
		Connection conn = null;
		String url = "jdbc:mysql://localhost:3306/";
		String dbName = "test";
		String driver = "com.mysql.jdbc.Driver";
		// String userName = "root";
		// String password = "mrinal88";
		String userName = "";
		String password = "";
		String s = null;
		try {
			Class.forName(driver).newInstance();
			conn = DriverManager
					.getConnection(url + dbName, userName, password);
			Statement st = conn.createStatement();
			ResultSet res = st
					.executeQuery("SELECT * FROM  Customer where Cust_name='"
							+ id + "' and Cust_pass='" + pass + "' ");
			while (res.next()) {
				s = res.getString("Trans_Code");
			}
			conn.close();

			return (s);

		} catch (Exception e) {
			e.printStackTrace();
			return ("Error" + e.toString());
		}
	}
	
	public static void main(String args[]){
		
		System.out.println("1");
		String temp = connect("amit","pass");
		System.out.println(temp);
	}
}
